package com.pan.tools;

import org.springframework.stereotype.Component;

import java.util.Random;


@Component
public class SaltTools {
    public static String getSalt(int len){
        Random random = new Random();
        char[] chs = new char[len];
        for (int i=0;i<len;i++) {
            int r = random.nextInt(52);
            if (r<10){
                chs[i] = (char) (r+48);
            } else if (r>=10&&r<36) {
                chs[i] = (char) (65+r-10);
            } else  {
                chs[i] = (char) (97+r-36);
            }
        }
        return String.valueOf(chs);
    }

    public static String[] getSalt(int len,int count){
        String[] strings = new String[count];
        for (int i=0;i<count;i++) {
            strings[i] = getSalt(len);
        }
        return strings;
    }
}
